package com.hee.erp.modules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hee.erp.modules.entity.CarCheckWarnRule;
import com.hee.erp.modules.mapper.CarCheckWarnRuleMapper;
import com.hee.erp.modules.service.ICarCheckWarnRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author weizehong
 * @since 2022-05-02
 */
@Service
@Transactional
public class CarCheckWarnRuleServiceImpl extends ServiceImpl<CarCheckWarnRuleMapper, CarCheckWarnRule> implements ICarCheckWarnRuleService {

    @Override
    public List<CarCheckWarnRule> listByCarId(String carId) {

        LambdaQueryWrapper<CarCheckWarnRule> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CarCheckWarnRule::getCarId, carId);

        List<CarCheckWarnRule> list = this.list(queryWrapper);
        if(list.size() == 0){
            CarCheckWarnRule carCheckWarnRule = new CarCheckWarnRule();
            carCheckWarnRule.setCarId(carId);
            list.add(carCheckWarnRule);
        }
        return list;
    }
}
